package cn.wbu.zyh.controller.admin;

import cn.wbu.zyh.constant.JwtClaimsConstant;
import cn.wbu.zyh.dto.EmployeeDTO;
import cn.wbu.zyh.dto.LoginDTO;
import cn.wbu.zyh.dto.EmployeePageQueryDTO;
import cn.wbu.zyh.entity.Employee;
import cn.wbu.zyh.properties.JwtProperties;
import cn.wbu.zyh.result.PageResult;
import cn.wbu.zyh.result.Result;
import cn.wbu.zyh.service.EmployeeService;
import cn.wbu.zyh.utils.JwtUtil;
import cn.wbu.zyh.vo.LoginVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin")
@Slf4j
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @GetMapping("/list")
    @ApiOperation("员工分页")
    public Result<PageResult> page(EmployeePageQueryDTO employeePageQueryDTO){
        log.info("员工分页查询,参数为：:{}",employeePageQueryDTO);
        PageResult pageResult = employeeService.pageQuery(employeePageQueryDTO);
        return Result.success(pageResult);
    }

    @PostMapping("/status/{status}")
    @ApiOperation("启用禁用员工账号")
    public Result startOrStop(@PathVariable Integer status,Long id){
        log.info("启用禁用员工账号：{}，{}",status,id);
        employeeService.startOrStop(status,id);
        return Result.success();
    }
    @PostMapping
    @ApiOperation("新增员工")
    public Result save(@RequestBody EmployeeDTO employeeDTO) {
        log.info("新增员工:{}",employeeDTO);
        employeeService.save(employeeDTO);
        return Result.success();
    }
    @PutMapping
    @ApiOperation("修改员工信息")
    public Result update(@RequestBody EmployeeDTO employeeDTO){
        log.info("修改员工信息：{}",employeeDTO);
        employeeService.update(employeeDTO);
        return Result.success();
    }
}
